package com.yuanduan.mplus.config;

import com.cj.framework.app.BaseApplication;
import com.cj.framework.util.RSAUtils;
import com.google.gson.Gson;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;

/**
 * Created by cj on 2016/5/27.
 * Email:781806481@qq.com
 */
public class Config {
    /**
     * RSA公钥
     */
    public static final String RSA_PUBLIC=
            "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQfqMPZGMQcd3JFZb+fggROEn9"+"\r" +
                    "jyUqcyvdIubGxVqISvod63xmlV+W4RYmc4xwoONg3pyKL7BwLfPz/+OU/cmNCzk2"+"\r" +
                    "xtnbExk5z48YIgh2GETWRZ/NIwvB5RIiAWmMl8w58Nn3M8nTuH812jspe2YYK5kI"+"\r" +
                    "vCG52IEokpkGEjkuDQIDAQAB";

    public static final String URL="http://121.41.108.127:8080/";

    //验证用户名和密码返回是否为合法用户
    public static final String VERIFYUSER="User.php?get=VerifyUser";

    //向用户发送6位验证码
    public static final String PHONECHECKCODE="User.php?get=PhoneVerificationCode";

    //用户注册
    public static final String USERREGISTRATION="User.php?get=UserRegistration";

    //获取用户个人信息
    public static final String USERINFO="User.php?get=UserInfo";

    //修改用户信息
    public static final String MODIFYUSERINFO="User.php?get=modifyUserInfo";

    //修改用户头像
    public static final String MODIFYUSERHEAD="User.php?get=modifyUserHead";

    //请求验证身份证
    public static final String APPLYIDCARD="User.php?get=ApplyReviewCardNumber";

    //刷新调取车队内点评信息
    public static final String REFRESHEVALUATION="Info.php?get=RefreshEvaluation";

    //获取某个用户的综合驾驶考评数据
    public static final String USERRESULTS="User.php?get=UserResults";

    //获取某个车队管理员的司机列表，驾驶行为分析界面列表
    public static final String DRIVINGINFORMATION="User.php?get=SimpleDrivingInformation";

    //获取某个车队管理员下属的司机列表
    public static final String DRIVERLISTOFCARADMIN="User.php?get=DriverListOfCarAdmin";

    //某一位司机某一周的安全驾驶详细评分报表
    public static final String USERSECURITY="User.php?get=UserSecurity";

    //某一位司机经济驾驶评分报表
    public static final String USERECONOMIC="User.php?get=UserEconomic";

    //某一驾驶评分属性分析
    public static final String ATTRIBUTEDETAIL="/User.php?get=AttributeDetails";

    //获取资讯
    public static final String CONSULT="Information/List.php?Type=1";

    //获取通知
    public static final String TONGZHI="Information/List.php?Type=2";

    //用户类型--- -1为游客，1为司机，2为管理员
    public static int userType=0;

    //用户绑定车辆
    public static final String USERLOOKCAR="User.php?get=UserLookCar";

    //返回某一辆车的信息
    public static final String CARINFO="Info.php?get=CarInfo";

    //某一周评分表
    public static final String SCOREREPORT="User.php?get=UserScoreReport";

    //行车记录检索信息
    public static final String RECORDSEARCH="User.php?get=DrivingRecordRetrieval";

    //行车记录详情
    public static final String RECORDPATH="User.php?get=DrivingPath";

    //司机当前积分奖励日志列表
    public static final String USERINTEGRAL="User.php?get=UserIntegral";

    //发送消息
    public static final String USERSENDMESSAGE="Info.php?get=UserSendMessage";

    //接收消息
    public static final String REFRESHMESSAGES="Info.php?get=RefreshMessages";

    //推广
    public static final String PROMOTION="Info.php?get=newInformation";

    public static final String PROMOTION1="Information/api.php?get=IndexBanner";

    //更改密码
    public static final String CHANGEPWD="User.php?get=ChangePassword";

    //更新身份证号码
    public static final String UPDATE_IDCARD="User.php?get=updateIdCardNumber";

    //更新身份证照片
    public static final String UPDATE_IDCARDIMAGE="User.php?get=UpdateIDCardImage";

    //获取身份证状态信息
    public static final  String USERIDENTITYAUTH="User.php?get=UserIdentityAuthentication";

    //重置密码获取验证码
    public static final String RESET_CODE="User.php?get=PhoneVerificationCode_reset";

    //反馈
    public static final String FEEDBACK="Info.php?get=feedback";

    //点评
    public static final String COMMENTS="Info.php?get=RefreshEvaluation";

    //进入密码修改界面
    public static final String INTO_RESETPWD="User.php?get=toChangePasswordView";

    //用户重置密码,用于忘记密码后重置界面
    public static final String RESET_PWD="User.php?get=ResetPassword";

    //头像所在位置
    public static String HEADLOCATION= BaseApplication.getContext().getFilesDir().getAbsolutePath()+File.separator+"head"+File.separator+"head.png";

    public static HashMap<String,String> translateMap(HashMap<String,String> hashMap){
        String key=null;
        String value=null;
        HashMap<String,String> result=new HashMap<String,String>();
        Iterator iterator=hashMap.keySet().iterator();
        while(iterator.hasNext()){
            key= (String) iterator.next();
            value=hashMap.get(key);
            value=RSAUtils.encryptWithRSA(value);
            result.put(key,value);
        }
        return result;
    }

    public static Object decry(Object object,Class<?> pClass){
        String str=RSAUtils.decryptWithRSA((String) object);
        Gson gson=new Gson();
        return gson.fromJson(RSAUtils.decryptWithRSA((String)object),pClass);
    }
}
